package com.zjj.day0425.date;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.YearMonth;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;




public class Date2 {
    public static void main(String[] args) {

        LocalDate birthDate = LocalDate.of(2003, 4, 5);
        LocalDate now = LocalDate.now();
        long daysSinceBirth = ChronoUnit.DAYS.between(birthDate, now);
        System.out.println("出生日期至今的天数: " + daysSinceBirth);

        LocalDateTime currentDateTime = LocalDateTime.now();
        LocalDateTime threeDaysLater = currentDateTime.plusDays(3);
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH:mm:ss");
        System.out.println("当前日期三天后的日期是: " + threeDaysLater.format(formatter));

        LocalDate productionDate = LocalDate.of(2025, 4, 25);
        LocalDate expirationDate = productionDate.plusDays(180);
        System.out.println("食品过期时间: " + expirationDate);

        LocalDate lastMonthThirdDay = YearMonth.now().minusMonths(1).atDay(3);
        DayOfWeek dayOfWeek = lastMonthThirdDay.getDayOfWeek();
        System.out.println("上个月的第三天是: " + dayOfWeek);

        LocalDate nextMonthLastThirdDay = YearMonth.now().plusMonths(1).atEndOfMonth().minusDays(2);
        System.out.println("下个月的倒数第3天是: " + nextMonthLastThirdDay);

        int dayOfYear = now.getDayOfYear();
        System.out.println("今天是今年的第 " + dayOfYear + " 天");

        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入一个年份: ");
        int year = scanner.nextInt();
        int februaryDays = YearMonth.of(year, 2).lengthOfMonth();
        System.out.println(year + " 年的2月份有 " + februaryDays + " 天");
    }
}    